using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MeetingRoom.Web.View;
using MeetingRoom.Domain;
using MeetingRoom.Service;
using MeetingRoom.Service.Workflow;

namespace MeetingRoom.Web.Presenter
{
    /// <summary>
    /// Summary description for IApplyPresenter
    /// </summary>
    public class ApplyPresenter
    {
        protected IApplyView view = null;

        protected IWorkflow workflow = null;

        protected IGetAllMeetingRoomTypes queryImplementor = null;

        public ApplyPresenter(IApplyView view, IWorkflow workflow)
        {
            this.view = view;
            this.workflow = workflow;
        }

        public IGetAllMeetingRoomTypes QueryImplementor
        {
            set
            {
                this.queryImplementor = value;
            }
        }

        public IApplyView View
        {
            set
            {
                this.view = value;
            }
        }

        public void InitView()
        {

        }

        public void Apply()
        {
            try
            {
                this.workflow.Execute(this.view.Schedule);
                view.Message = "Apply successed";
            }
            catch (WorkflowException ex)
            {
                view.Message = "Apply Failed";
            }
        }
    }
}